using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Practices.ObjectBuilder;
using Microsoft.Practices.CompositeWeb;
using System.Transactions;
using GC2.Entities.Admin;
using GC2.ExceptionHandler.Services;
using GC2.DataAccess.DAAdmin;

namespace GC2.Bussines.BMAdmin
{
    public class BMProveedores
    {
        public BMProveedores(string coneccion) 
        {
            this.Connection = coneccion;
        }

        private string connection = "";
        public string Connection
        {
            get { return connection; }
            set { connection = value; }
        }

        private Proveedores oProveedor = new Proveedores();
        private List<Proveedores> listProveedores = new List<Proveedores>();
        private DAProveedores daProveedores = new DAProveedores();

        #region BMProveedoresSearch
        public List<Proveedores> BMProveedoresSearch(Proveedores proveedor)
        {
            try
            {
                listProveedores = daProveedores.DAProveedoresSearch(connection, proveedor);
                return listProveedores;
            }
            catch (Exception ex)
            {
                ExceptionBM exNew = new ExceptionBM();
                throw new System.Exception(exNew.exBM(ex.ToString()).ToString());
            }
        }
        #endregion

        #region BMProveedoresInsert
        public Proveedores BMProveedoresInsert(Proveedores proveedor)
        {
            try
            {
                proveedor = daProveedores.DAProveedoresInsert(connection, proveedor);
                return proveedor;
            }
            catch (Exception ex)
            {
                ExceptionBM exNew = new ExceptionBM();
                throw new System.Exception(exNew.exBM(ex.ToString()).ToString());
            }
        }
        #endregion

        #region BMProveedoresUpdate
        public void BMProveedoresUpdate(Proveedores proveedor)
        {
            try
            {
                daProveedores.DAProveedoresUpdate(connection, proveedor);
            }
            catch (Exception ex)
            {
                ExceptionBM exNew = new ExceptionBM();
                throw new System.Exception(exNew.exBM(ex.ToString()).ToString());
            }
        }
        #endregion

        #region BMProveedoresUpdateSaldo
        public void BMProveedoresUpdateSaldo(Proveedores proveedor)
        {
            try
            {
                daProveedores.DAProveedoresUpdateSaldo(connection, proveedor);
            }
            catch (Exception ex)
            {
                ExceptionBM exNew = new ExceptionBM();
                throw new System.Exception(exNew.exBM(ex.ToString()).ToString());
            }
        }
        #endregion

        #region BMProveedordsGetOne
        public Proveedores BMProveedoresGetOne(Proveedores proveedor)
        {
            try
            {
                oProveedor = daProveedores.DAProveedoresGetOne(connection, proveedor);
                return oProveedor;
            }
            catch (Exception ex)
            {
                ExceptionBM exNew = new ExceptionBM();
                throw new System.Exception(exNew.exBM(ex.ToString()).ToString());
            }
        }
        #endregion
    }
}
